package com.topisv.tms.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.User;

public interface UserDao extends PagingAndSortingRepository<User, Long>,JpaSpecificationExecutor<User> {
	
	User findByUserId(String userId);
	
	User findByUsername(String loginName);
	
	List<User> findByRealname(String name);
	
	User findByJobuuid(String jobuuid);
	
	List<User> findByCustomerCode(String customerCode);
	
	List<User> findByStatus(String status);

	List<User> findByDepartmentId(Long id);
	
	@Query("select t from User t where t.userType=? and t.customerCode=?")
	List<User> loadCustomerTypeUser(String userType, String customerCode);

	@Query("select t from User t where t.areagroups like ? ")
	List<User> loadByWarehouseCode(String warehouseCode);
	@Query("select t from User t where t.areagroups like ?1 and  t.customers like ?2")
	List<User> findByWareHouseCodeAndCustomerCode(String warehouseCode,String customerCode);
}
